//fieldpylon.txt - This is part of a field of pylons which all explode when someone gets
//  close. They then recharge themselves eventually, unless the control turning them off is flipped.
// The pylons are set off by sending message 105.
//Cell 0 - The number of d8 damage it does.
//Cell 1,2 - A stuff done flag. If > 0, this mine has been deactivated or was set off
//Cell 3 - This is the number of the previous pylon in the chain, 0 if none.
//Cell 4 - This is the number of the next pylon in the chain, 0 if none.
// Cell 5 - If 1, triggered by any friendly character

beginobjectscript; // mine

variables;
short near_char;
short r1;
short icon_off = 0;
short i;
short ive_gone_off = 0;
short wisp_counter = 0;
short turn_on_counter = 0;
short cur_tick;
short cur_tick2;

body;

beginstate INIT_STATE;
	cur_tick = get_current_tick();
	cur_tick2 = get_current_tick();
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; 
	if (gf(34,22) != 1)
		end();

	if (get_ran(1,0,100) < 40)
		shoot_projectile(ME,133,34);
	if (get_ran(1,0,100) < 40)
		shoot_projectile(ME,134,34);
		
	// text bubble
	if (get_ran(1,0,8) == 4)
		create_text_bubble("Hmmmmm!");

	if (((is_group()) && (tick_difference(cur_tick,get_current_tick()) > 4)) ||
	((is_combat()) && (tick_difference(cur_tick,get_current_tick()) > 1)))
	{
		cur_tick = get_current_tick();
		if ((gf(34,24) > 0) && (gf(34,25) > 0))
			end();
			else {
				if ((gf(34,24) > 0) || (gf(34,25) > 0)) {
					print_str_color("The machine in the center sprays out excess power from one conduit.",2);
					r1 = get_ran(10,1,6);
					}
					else {
						print_str_color("The machine in the center sprays out excess power from both conduits!",2);
						r1 = get_ran(25,1,6);
						}
		
				pc_heard_sound(238); 
				run_sparkles_on_object(ME,177,1,4);
				create_missile_spiral(155,40,8,2);
				damage_nearby(r1,8,1,0);

				}
		}	


break;

beginstate USE_STATE;
	begin_talk_mode(23);
break;